#include "stdafx.h"

const int MOUSE_MOVE_SENSETIVE = 0; // value + 1 pixel

class CameraStrategyFree : public CameraStrategy
{
public:
	CameraStrategyFree() {}
	~CameraStrategyFree() {}


	void update(float dt)
	{
		if (!camera) return;
		if (!g_input) return;

		if (g_input->isActionDown(ACTION_CAMERA_MOVE_DOWN))
		{
			camera->moveLocal(zAxisf);
		}
		else if (g_input->isActionDown(ACTION_CAMERA_MOVE_UP))
		{
			camera->moveLocal(-zAxisf);
		}
		else if (g_input->isActionDown(ACTION_CAMERA_MOVE_RIGHT))
		{
			camera->moveLocal(xAxisf);
		}
		else if (g_input->isActionDown(ACTION_CAMERA_MOVE_LEFT))
		{
			camera->moveLocal(-xAxisf);
		}

		//if (g_input->didKeyJustGoDown(VK_RBUTTON))
		//{
		//	camera->pitch(0.785f);
		//}
		//if (g_input->didKeyJustGoDown(VK_LBUTTON))
		//{
		//	camera->yaw(0.785f);
		//}
		if (g_input->isKeyDown(VK_RBUTTON))
		{
			MoveParam moveDt;
			g_input->getMove(moveDt);
			if (abs(moveDt.left.y) > MOUSE_MOVE_SENSETIVE)
			{
				camera->pitch(-moveDt.left.y);
			}
			if (abs(moveDt.left.x) > MOUSE_MOVE_SENSETIVE)
			{
				camera->yaw(-moveDt.left.x);
			}
		}
	}
};

CameraStrategy* createFreeCameraStrategy()
{
	return new CameraStrategyFree;
}
